"""
管理Streamlit会话状态
"""
import streamlit as st
from models.scene import Scene
from models.parameter import Parameter


def init_session_state():
    """
    初始化会话状态
    """
    default_states = {
        "current_scene": None,
        "parameters": {},
        "raw_data": None,
        "cleaned_data": None,
        "transformed_data": None,
        "calculation_result": None,
        "evaluation_report": None
    }
    
    for key, value in default_states.items():
        if key not in st.session_state:
            st.session_state[key] = value


def set_current_scene(scene: Scene):
    """
    设置当前场景
    """
    st.session_state.current_scene = scene


def add_parameter(param: Parameter):
    """
    添加参数
    """
    st.session_state.parameters[param.name] = param.value


def clear_data_state():
    """
    清除数据相关状态
    """
    st.session_state.raw_data = None
    st.session_state.cleaned_data = None
    st.session_state.transformed_data = None
    st.session_state.calculation_result = None
    st.session_state.evaluation_report = None